//一分钟了解完TS中的泛型
//https://juejin.cn/post/7027798242049916936

type User = {
  name: string
  age: number
}

type Goods = {
  id: number
  goodsName: string
}

// <T>  表示类型的参数  后期 传递啥类型 我们的T 就是什么类型
type Data<T> = {
  msg: string
  code: number
  data: T
}

// 泛型类型数据

type UserData = Data<User>

type GoodsData = Data<Goods>

// 基于泛型类型定义对象
let resUser: UserData = {
  msg: '哈哈',
  code: 200,
  data: {
    name: 'zs',
    age: 19,
  },
}
console.log(resUser)

let resGoods: GoodsData = {
  msg: '呵呵',
  code: 401,
  data: {
    id: 100,
    goodsName: '背带裤篮球',
  },
}

console.log(resGoods)
